#include<bits/stdc++.h>
using namespace std;
int T,n,m,L,V;
double EPS=1e-7;
int d[100005],v[100005],a[100005],p[100005];
vector<pair<double,double> > ovs;
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%d",&T);
    while(T--){
        scanf("%d%d%d%d",&n,&m,&L,&V);
        memset(d,0,sizeof(d));
        memset(v,0,sizeof(v));
        memset(a,0,sizeof(a));
        memset(p,0,sizeof(p));
        ovs=vector<pair<double,double> >();
        int flagA=1,flagB=1;
        for(int i=1;i<=n;i++){
            scanf("%d%d%d",&d[i],&v[i],&a[i]);
            if(a[i]!=0)flagA=0;
            if(a[i]<=0)flagB=0;
        }
        for(int i=1;i<=m;i++){
            scanf("%d",&p[i]);
        }
        sort(p+1,p+m+1);
        if(flagA){
            int ans1=0;
            for(int i=1;i<=n;i++){
                if(v[i]>V&&d[i]<=p[m])ans1++;
            }
            int ans2=1;
            if(ans1==0)ans2=0;
            printf("%d %d\n",ans1,m-ans2);
        }
        else if(flagB){
            int ans1=0;
            for(int i=1;i<=n;i++){
                if(d[i]>p[m])continue;
                int s=p[m]-d[i];
                double speed=sqrt((double)(v[i]*v[i]+2*a[i]*s));
                if(speed-(double)(V)>EPS){
                    ans1++;
                }
            }
            int ans2=1;
            if(ans1==0)ans2=0;
            printf("%d %d\n",ans1,m-ans2);
        }
        else{
            int ans1=0;
            for(int i=1;i<=n;i++){
                if(a[i]==0){
                    if(v[i]>V&&d[i]<=p[m]){
                        ovs.push_back({(double)(d[i]),(double(L))});
                    }
                }
                else if(a[i]>0){
                    double xx=(double)(V*V-v[i]*v[i]);
                    double yy=(double)(2*a[i]);
                    double st=xx/yy+(double)(d[i]);
                    if(st-(double)(p[m])<=EPS){
                        ovs.push_back({st,(double)(L)});
                    }
                }
                else if(a[i]<0){
                    double xx=(double)(V*V-v[i]*v[i]);
                    double yy=(double)(2*a[i]);
                    double ed=xx/yy+(double)(d[i]);
                    for(int j=1;j<=m;j++){
                        if(p[j]>=d[i]&&(double)(p[j])<=ed){
                            ovs.push_back({d[i],min(ed,(double)(L))});
                            break;
                        }
                    }
                }
            }
            int ans2=0;
            for(int s=0;s<(1<<m);s++){
                int ff=1,cntt;
                for(int j=0;j<ovs.size();j++){
                    int fl=0,cnt=0;
                    for(int i=1;i<=m;i++){
                        if(((s>>(i-1))&1)==0)continue;
                        cnt++;
                        if((ovs[j].first-(double)(p[i]))<=0&&(ovs[j].second-(double)(p[i]))>=0){
                            fl=1;
                        }
                    }
                    if(fl==0)ff=0;
                    cntt=cnt;
                }
                if(ff){
                    ans2=max(ans2,m-cntt);
                }
            }
            printf("%d %d\n",ovs.size(),ans2);
        }
    }
    return 0;
}
